package com.zhentao.config.swaggergateway;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
       		    .enable(true)		// 是否启用 swagger
                .apiInfo(apiInfo())	// 用来创建该API的基本信息，展示在文档的页面中（自定义展示的信息）
                .select()			// 设置哪些接口暴露，扫描所有
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }
    
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                // 设置标题
                .title("标题：振涛臻选-前台管理系统_接口文档")
                // 描述
                .description("描述：...")
                // 作者信息
                .contact(new Contact("byd","略","2913130665@qq.com"))
                // 版本
                .version("1.0")
                .build();
    }
}
